# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=openvpn3
pkgver=3.7
pkgrel=0
pkgdesc="C++ class library that implements the functionality of an OpenVPN client"
url="https://github.com/OpenVPN/openvpn3"
arch="all !s390x" # broken tests due to endianness assumptions
license="AGPL-3.0-only"
depends_dev="lz4-dev asio-dev libcap-dev"
makedepends="cmake samurai gtest-dev $depends_dev"
subpackages="$pkgname-dev"
source="https://github.com/OpenVPN/openvpn3/archive/refs/tags/release/$pkgver/openvpn3-$pkgver.tar.gz
	unvendor.patch
	"
builddir="$srcdir/openvpn3-release-$pkgver"

[ "$CARCH" = "riscv64" ] && options="$options textrels"

build() {
	cmake -G Ninja -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel
	cmake --build build
}

check() {
	cd build
	test/unittests/coreUnitTests \
		--gtest_filter=-buffer_ip.ipv6
}

package() {
	# no cmake install target
	install -Dm755 build/test/ovpncli/ovpncli -t "$pkgdir"/usr/bin
	mkdir "$pkgdir"/usr/include
	mv openvpn "$pkgdir"/usr/include
}

sha512sums="
de95bd2b1a01179aa81e1612be175540c2486b856f66880372d09966655bbbadd71d874ed49b032566dde2896207bc76298c5cfcf73e86272c04d5aaa977d660  openvpn3-3.7.tar.gz
83bf9085f97a08abccb583a5bd0b15258594b2746e45128c1f987445a92c1de0ea6ef80b750a12dab4baf4aba6fe94d44ff4e8b886796bd107e5cd3568755c5d  unvendor.patch
"
